<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shops', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('店铺表');
            $table->string('name')->nullable()->comment('店名');
            $table->integer('user_id')->unsigned()->comment('用户id');
            $table->string('face_picture')->nullable()->comment('店铺图片');
            $table->string('begin_business_hours')->nullable()->comment('开始营业时间');
            $table->string('end_business_hours')->nullable()->comment('结束营业时间');
            $table->dateTime('begin_free_time')->nullable()->comment('开始空闲时间');
            $table->dateTime('end_free_time')->nullable()->comment('结束空闲时间');
            $table->string('province')->nullable()->comment('省');
            $table->string('city')->nullable()->comment('市');
            $table->string('district')->nullable()->comment('区');
            $table->enum('status', ['padding', 'pass', 'fail'])->default('padding')->comment('审核状态');
            $table->boolean('recommended')->default(false)->comment('是否推荐');
            $table->smallInteger('sort')->default(0)->comment('排序');
            $table->timestamps();
        });

        Schema::create('products', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('商品表');
            $table->integer('shop_id')->comment('商店id');
            $table->string('title')->comment('标题');
            $table->string('subtitle')->nullable()->comment('副标题');
            $table->string('image')->nullable()->comment('主图');
            $table->string('contact_phone', 20)->nullable()->comment('联系电话');
            $table->text('content')->nullable()->comment('内容(文)');
            $table->string('pictures')->nullable()->comment('内容(图)');
            $table->text('service_time')->nullable()->comment('服务时间');
            $table->string('province')->nullable()->comment('省');
            $table->string('city')->nullable()->comment('市');
            $table->string('district')->nullable()->comment('区');
            $table->string('address')->nullable()->comment('详细地址');
            $table->string('longitude', 10)->nullable()->comment('经度');
            $table->string('latitude', 10)->nullable()->comment('纬度');
            $table->tinyInteger('stock_amount')->default(0)->comment('库存');
            $table->tinyInteger('view_amount')->default(0)->comment('浏览量');
            $table->tinyInteger('sell_amount')->default(0)->comment('成交量');
            $table->boolean('recommended')->default(false)->comment('是否推荐');
            $table->tinyInteger('sort')->default(0)->comment('排序');
            $table->boolean('is_show')->default(true)->comment('是否展示');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shops');
        Schema::dropIfExists('products');
    }
}
